# $Id: PKGBUILD 85074 2013-02-27 10:42:57Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=firefox-adblock-plus
pkgver=2.2.3
_addons_file=192004
pkgrel=2
pkgdesc="plugin for firefox which block ads and banners"
arch=('any')
url="http://adblockplus.org/"
license=('GPL')
depends=("firefox")
makedepends=('unzip')
noextract=("adblock_plus-$pkgver-fx+tb+fn+sm.xpi")
source=(https://addons.mozilla.org/firefox/downloads/file/${_addons_file}/adblock_plus-$pkgver-fx+tb+fn+sm.xpi)
md5sums=('07607a3cb349eeccfc7768b5f4f2aaae')

package() {
#  _ffver=`pacman -Q firefox | cut -f2 -d\ | cut -f1-2 -d.`
#  depends=("firefox>=${_ffver}" "firefox<=${_ffver/0/99}")

  cd $srcdir
  [ $NOEXTRACT -eq 1 ] || unzip adblock_plus-$pkgver-fx+tb+fn+sm.xpi
  local emid=$(sed -n -e '/<\?em:id>\?/!d; s/.*\([\"{].*[}\"]\).*/\1/; s/\"//g; p; q' install.rdf)
  local dstdir=$pkgdir/usr/lib/firefox/extensions/${emid}
  [ -n ${emid} ] || return 1
  install -d $dstdir
#  sed -i 's#<em:maxVersion>.*</em:maxVersion>#<em:maxVersion>20.*</em:maxVersion>#' install.rdf
  cp -R * $dstdir
  rm $dstdir/*.xpi
  find $pkgdir -type d -exec chmod 0755 {} \;
  find $pkgdir -type f -exec chmod 0644 {} \;
}
